package com.zzw.spring.quartz;

import org.quartz.*;
import org.quartz.impl.JobDetailImpl;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.triggers.CronTriggerImpl;

import java.text.ParseException;

public class CronTriggerRunner {

    public static void main(String[] args) throws ParseException, SchedulerException {
        JobDetail jobDetail = new JobDetailImpl("job1_2","jGroup1",SimpleJob.class);
        CronTriggerImpl cronTrigger = new CronTriggerImpl("trigger1_2","tgroup1");
        CronExpression cexp = new CronExpression("0/5 * * * * ?");
        cronTrigger.setCronExpression(cexp);
        SchedulerFactory schedulerFactory = new StdSchedulerFactory();
        Scheduler scheduler = schedulerFactory.getScheduler();
        scheduler.scheduleJob(jobDetail,cronTrigger);
        scheduler.start();
    }
}
